home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 February: Technology Seed / Mac Tech Seed Feb '97.toast / ODF Release 3 / Developer University / DU Projects / Talker Part / Sources / Part.cpp < prev    next >
Encoding:
Text File  |  1996-12-11  |  3.0 KB  |  110 lines  |  [TEXT/CWIE]

  1. //========================================================================================
  2. //    Release Version:    $ ODF 3 $
  3. //    Copyright:    (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  4.  
  5. //================================================================================
  6. #include "Talker.hpp"
  7.  
  8. #ifndef PART_H
  9. #include "Part.h"
  10. #endif
  11.  
  12. #ifndef CONTENT_H
  13. #include "Content.h"
  14. #endif
  15.  
  16. #ifndef BINDING_K
  17. #include "Binding.k"
  18. #endif
  19.  
  20. #ifndef FRAME_H
  21. #include "Frame.h"
  22. #endif
  23.  
  24. #ifndef SELECTION_H
  25. #include "Selection.h"
  26. #endif
  27.  
  28. // ----- Framework Layer -----
  29. #ifndef FWPRESEN_H
  30. #include "FWPresen.h"        // FW_CPresentation
  31. #endif
  32.  
  33. #ifndef FWABOUT_H
  34. #include "FWAbout.h"        //::FW_About()
  35. #endif
  36.  
  37. //==============================================================================
  38. #ifdef FW_BUILD_MAC
  39. #pragma segment Talker
  40. #endif
  41.  
  42. FW_DEFINE_AUTO(CTalkerPart)
  43. //==============================================================================
  44. CTalkerPart::CTalkerPart(ODPart* odPart)
  45.   :    FW_CPart(odPart, FW_gInstance, kPartInfoID),
  46.     fPresentation(NULL),
  47.     fPartContent(NULL)
  48. {
  49.     FW_END_CONSTRUCTOR
  50. }
  51.  
  52. //--------------------------------------------------------------------------------
  53. CTalkerPart::~CTalkerPart()
  54. {
  55.     FW_START_DESTRUCTOR
  56. }
  57.  
  58. //--------------------------------------------------------------------------------
  59. void 
  60. CTalkerPart::Initialize(Environment* ev, ODStorageUnit* storageUnit, 
  61.                         FW_Boolean fromStorage)    // Override
  62. {
  63.     FW_CPart::Initialize(ev, storageUnit, fromStorage);
  64.     CTalkerSelection* selection = FW_NEW(CTalkerSelection, (ev, fPartContent));
  65.     const ODType kMainPresentation = "Apple:Presentation:Talker";
  66.     const FW_Boolean kDefaultPresentation = true;
  67.     fPresentation = RegisterPresentation(ev, kMainPresentation, 
  68.                         kDefaultPresentation, selection);
  69.     RegisterKind(ev, 'TEXT', kODPlatformDataType, FW_kDataInterchangeStorage, FW_kImport);
  70.     RegisterKind(ev, 'PICT', kODPlatformDataType, FW_kDataInterchangeStorage, FW_kImport);
  71. }
  72.  
  73. //--------------------------------------------------------------------------------
  74. FW_CFrame* 
  75. CTalkerPart::NewFrame(Environment* ev, ODFrame* odFrame,
  76.                         FW_CPresentation* presentation, FW_Boolean fromStorage)    // Override
  77. {
  78.     FW_UNUSED(fromStorage);
  79.     return FW_NEW(CTalkerFrame, (ev, odFrame, presentation, fPartContent));
  80. }
  81.  
  82. //------------------------------------------------------------------------------
  83. FW_CContent* 
  84. CTalkerPart::NewPartContent(Environment* ev)
  85. {
  86.     fPartContent = FW_NEW(CTalkerContent, (ev, this));
  87.     return fPartContent;
  88. }
  89.  
  90. //------------------------------------------------------------------------------
  91. FW_Handled 
  92. CTalkerPart::DoAbout(Environment* ev)
  93. {
  94.     ::FW_About(ev, this, kAbout);
  95.     
  96.     return FW_kHandled;
  97. }
  98.  
  99. //------------------------------------------------------------------------------
  100. void
  101. CTalkerPart::PartChanged(Environment* ev, FW_Boolean invalidateOnly)
  102. {    
  103.     if (!invalidateOnly) {
  104.         this->Changed(ev);                    // enable Save
  105.         fPresentation->ContentUpdated(ev);    // containers must update links
  106.     }
  107.     fPresentation->Invalidate(ev);            // redraw all display frames
  108. }
  109.  
  110.